from django.shortcuts import render
from rest_framework.utils import json
from rest_framework.views import APIView
from rest_framework.response import Response

class LoginView(APIView):
    def post(self,request,*args,**kwargs):
        print(request.data)
        return Response({"code":200,"data":{"status":True,"token":'3292377c-4007-42ea-baba-c7945016fa24'}})

class getGoodsList(APIView):
    def get(self,request,*args,**kwargs):
        print(request)
        goodsList=[
            {'userId':1,'id':1,"title":'农夫山川',"introduce":"农夫山泉一直以来都以卓越的品质和大胆开创性的尝试，成为业界的标杆式企业。每一个员工的坚守成就了农夫山泉几十年的品质。"},
            {'userId':1,'id':2,"title":'可口可乐',"introduce":'可口可乐 诞生于1886年，以其畅爽怡神的口味和自由活力的品牌形象备受消费者，特别是年轻消费者的欢迎。'},
            {'userId':1,'id':3,"title":'雪碧',"introduce":'作为可口可乐公司标志性的柠檬味汽水品牌，【雪碧】以其丰富的气泡、清爽的柠檬味、酷爽的体验一直深受全球消费者的喜爱。'},
            {'userId':1,'id':4,"title":'芬达',"introduce":'【芬达】汽水是可口可乐公司的多果味汽水品牌，旗下包含橙味、苹果味、蜜桃味等多种果味汽水，以及【芬达】黑魔钥、“蓝色”【芬达】等创意概念的果味汽水。'},
            {'userId':1,'id':5,"title":'怡泉',"introduce":'【怡泉】是一个历史悠久的经典汽水品牌，1783 年源自于英国。 【怡泉】苏打水传承英伦经典工艺，为中国消费者日益提升的品质生活需求提供精致的产品选择。'},
            {'userId':1,'id':6,"title":'柠檬道',"introduce":'【柠檬道】"Lemon-Dou"是可口可乐公司的酒精饮料品牌，其灵感来源于居酒屋经典的整柠制酒工艺'},
            {'userId':1,'id': 7, "title": '冰露', "introduce": '【冰露】是可口可乐公司旗下包装饮用水品牌。口感甘冽，清澈透明，致力于满足消费者对高品质饮水的需求。'},
            {'userId':1,'id': 8, "title": '纯悦', "introduce": '【纯悦】是可口可乐公司旗下包装饮用水及风味饮品品牌，采用全球可口可乐系统严格的质量管控体系为追求品质生活的都市消费者带来舒适的饮用体验。'},
            {'userId':1,'id': 9, "title": '爆锐', "introduce": 'POWERADE是可口可乐公司于1992年推出的运动饮料，并成为奥运会官方运动饮料。'},
            {'userId':1,'id': 10, "title": '水动乐', "introduce": '【水动乐】于2014年在中国大陆推出，是可口可乐公司年销售额超过10亿美元的品牌之一。 '},
            {'userId':1,'id': 11, "title": 'COSTA', "introduce": '【COSTA】的故事始于1971年的伦敦老天堂街，COSTA两兄弟秉持着对咖啡的热情将高品质咖啡从意大利带到了英国'},
            {'userId':1,'id': 12, "title": '淳茶舍', "introduce": '【淳茶舍】是可口可乐公司旗下的无糖茶饮料品牌。原味/调味茶饮料。甄选茶叶、精心泡制，纯正茶味让人慢享一刻惬意。'},
            {'userId':1,'id': 13, "title": '阳光', "introduce": '【阳光】是可口可乐公司旗下的茶饮料品牌。'},
            {'userId':1,'id': 14, "title": '美汁源', "introduce": '【美汁源】进入中国十余年，致力于通过高品质的果汁饮料，为中国消费者带来愉悦的饮用体验。“果然活力”的精彩。'},
        ]
        return Response({"code":200,"message":'请求成功',"data":goodsList})

class getUserList(APIView):
    def get(self,request,*args,**kwargs):
        print(request)
        userList=[
            {
                "UserID": 1,
                "nickName":'ADL',
                "userName":'ADL',
                "role": [{"role":1,"roleName":"管理员"},{"role":2,"roleName":"普通用户"}]
            },
            {
                "UserID": 2,
                "nickName": 'ADeL',
                "userName":'ADel',
                "role": [{"role":2,"roleName":"普通用户"}]
            }
        ]
        return Response({"code":200,"message":'请求成功',"data":userList})

class getRoleList(APIView):
    def get(self,request,*args,**kwargs):
        print(request)
        RoleList=[
            {
                "roleName":'管理员',
                "roleID":1,
                "authority":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
            },
            {
                "roleName": '普通用户',
                "roleID":2,
                "authority":[1,2,3,4,5,6,7,8,9,10]
            }
        ]
        return Response({"code":200,"message":'请求成功',"data":RoleList})

class getAuthorityList(APIView):
    def get(self,request,*args,**kwargs):
        print(request)
        AthorityList=[
            {
                "name":'订单列表',
                "roleID":1,
                "viewRole": "",
                "roleList":[
                    {
                        "name":'订单详情',
                        "roleID":4,
                        "viewRole":"",
                        "roleList":[{"name":"审核","roleID":5}]
                    },
                    {
                        "name": '查看',
                        "roleID": 2,
                        "viewRole": "",
                        "roleList": []
                    },
                    {
                        "name": '删除',
                        "roleID": 3,
                        "viewRole": "",
                        "roleList": []
                    }
                ]
            },
            {
                "name": '商品列表',
                "roleID": 6,
                "viewRole":"",
                "roleList": [
                    {
                        "name": '订单详情',
                        "roleID": 5,
                        "viewRole": "",
                        "roleList": []
                    },
                    {
                        "name": '查看',
                        "roleID": 7,
                        "viewRole": "",
                        "roleList": []
                    },
                    {
                        "name": '删除',
                        "roleID": 8,
                        "viewRole": "",
                        "roleList": []
                    }
                ]
            },
            {
                "name": '用户列表',
                "roleID": 11,
                "viewRole": "",
                "roleList": [
                    {
                        "name": '订单详情',
                        "roleID": 9,
                        "viewRole": "",
                        "roleList": []
                    },
                    {
                        "name": '查看',
                        "roleID": 10,
                        "viewRole": "",
                        "roleList": []
                    },
                    {
                        "name": '删除',
                        "roleID": 12,
                        "viewRole": "",
                        "roleList": []
                    }
                ]
            },
            {
                "name": '角色管理',
                "roleID": 15,
                "viewRole": "",
                "roleList": [
                    {
                        "name": '订单详情',
                        "roleID": 14,
                        "viewRole": "",
                        "roleList": []
                    },
                    {
                        "name": '查看',
                        "roleID": 13,
                        "viewRole": "",
                        "roleList": []
                    },
                    {
                        "name": '删除',
                        "roleID": 16,
                        "viewRole": "",
                        "roleList": []
                    }
                ]
            },
        ]
        return Response({"code":200,"message":"请求成功","data":AthorityList})
